{
 "cells": [
  {
   "cell_type": "code",
   "execution_count": 1,
   "id": "09a97616-d8b3-4ea1-b5d8-14a18bd16a94",
   "metadata": {},
   "outputs": [],
   "source": [
    "import jwt\n",
    "from jinja2 import Template"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 16,
   "id": "2dfa7b51-cfac-4671-9041-866d6a5f7bf4",
   "metadata": {},
   "outputs": [],
   "source": [
    "from datetime import date, datetime, time, timedelta\n",
    "\n",
    "from my import workTimeCalculator as worktime"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 17,
   "id": "184700a1-afe3-46b4-af48-fa5d665d40c7",
   "metadata": {},
   "outputs": [],
   "source": [
    "# 设置请假时间段（可跨天）\n",
    "leave_start = datetime(2025, 5, 29, 23, 0)  # 星期四晚上\n",
    "leave_end = datetime(2025, 6, 1, 2, 0)  # 跨到星期一凌晨\n",
    "\n",
    "# 定义每天的工作时间段（time 对象）\n",
    "work_periods = [\n",
    "    (time(7, 30), time(11, 30)),\n",
    "    (time(13, 0), time(17, 0)),\n",
    "    (time(19, 0), time(22, 0)),\n",
    "]\n",
    "\n",
    "# 定义节假日列表（date 对象）\n",
    "holidays = {\n",
    "    date(2025, 5, 29),  # 假设是节日\n",
    "    # date(2025, 6, 1),  # 假设是调休周末（虽然是周日）\n",
    "}"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 19,
   "id": "cc2e2ef9-5d1c-4185-9ad2-8f36fb01b535",
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "\n",
      "请假期间占用的工作时间段共计: 1320 分钟（即 22.0 小时）\n"
     ]
    }
   ],
   "source": [
    "# 计算总工作时间内的请假时长\n",
    "total_minutes = worktime.calculate_work_time_overlap(\n",
    "    leave_start, leave_end, work_periods, holidays\n",
    ")\n",
    "total_hours = round(total_minutes / 60.0, 2)\n",
    "\n",
    "print(f\"\\n请假期间占用的工作时间段共计: {total_minutes} 分钟（即 {total_hours} 小时）\")"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 1,
   "id": "36a5f54d-2553-4d65-a5ee-45c2b855e8ed",
   "metadata": {},
   "outputs": [],
   "source": [
    "from my import recommender\n",
    "from collections import defaultdict"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 2,
   "id": "96a8066f-1242-4d74-8501-490dfe8dc21d",
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "A: {\"B\": 0.4082482904638631, \"C\": 0.4082482904638631, \"D\": 0.3333333333333333}\n",
      "B: {\"A\": 0.4082482904638631, \"C\": 0.0, \"D\": 0.4082482904638631}\n",
      "C: {\"A\": 0.4082482904638631, \"B\": 0.0, \"D\": 0.4082482904638631}\n",
      "D: {\"A\": 0.3333333333333333, \"B\": 0.4082482904638631, \"C\": 0.4082482904638631}\n"
     ]
    },
    {
     "ename": "NameError",
     "evalue": "name 'w' is not defined",
     "output_type": "error",
     "traceback": [
      "\u001b[31m---------------------------------------------------------------------------\u001b[39m",
      "\u001b[31mNameError\u001b[39m                                 Traceback (most recent call last)",
      "\u001b[36mCell\u001b[39m\u001b[36m \u001b[39m\u001b[32mIn[2]\u001b[39m\u001b[32m, line 1\u001b[39m\n\u001b[32m----> \u001b[39m\u001b[32m1\u001b[39m \u001b[43mrecommender\u001b[49m\u001b[43m.\u001b[49m\u001b[43mmain\u001b[49m\u001b[43m(\u001b[49m\u001b[43m)\u001b[49m\n",
      "\u001b[36mFile \u001b[39m\u001b[32m/work/my/recommender.py:46\u001b[39m, in \u001b[36mmain\u001b[39m\u001b[34m()\u001b[39m\n\u001b[32m     43\u001b[39m \u001b[38;5;28;01mfor\u001b[39;00m k, v \u001b[38;5;129;01min\u001b[39;00m similarity(users).items():\n\u001b[32m     44\u001b[39m     \u001b[38;5;28mprint\u001b[39m(\u001b[33mf\u001b[39m\u001b[33m'\u001b[39m\u001b[38;5;132;01m{\u001b[39;00mk\u001b[38;5;132;01m}\u001b[39;00m\u001b[33m: \u001b[39m\u001b[38;5;132;01m{\u001b[39;00mjson.dumps(v)\u001b[38;5;132;01m}\u001b[39;00m\u001b[33m'\u001b[39m)\n\u001b[32m---> \u001b[39m\u001b[32m46\u001b[39m rank = recommend(\u001b[33m'\u001b[39m\u001b[33mC\u001b[39m\u001b[33m'\u001b[39m, users, \u001b[43mw\u001b[49m, \u001b[32m3\u001b[39m)\n\u001b[32m     47\u001b[39m \u001b[38;5;28;01mfor\u001b[39;00m k, v \u001b[38;5;129;01min\u001b[39;00m \u001b[38;5;28msorted\u001b[39m(rank.items(), key=\u001b[38;5;28;01mlambda\u001b[39;00m item: item[\u001b[32m1\u001b[39m], reverse=\u001b[38;5;28;01mTrue\u001b[39;00m):\n\u001b[32m     48\u001b[39m     \u001b[38;5;28mprint\u001b[39m(\u001b[33mf\u001b[39m\u001b[33m'\u001b[39m\u001b[38;5;132;01m{\u001b[39;00mk\u001b[38;5;132;01m}\u001b[39;00m\u001b[33m: \u001b[39m\u001b[38;5;132;01m{\u001b[39;00mv\u001b[38;5;132;01m}\u001b[39;00m\u001b[33m'\u001b[39m)\n",
      "\u001b[31mNameError\u001b[39m: name 'w' is not defined"
     ]
    }
   ],
   "source": [
    "recommender.main()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 3,
   "id": "750f7c77-6705-4402-af00-a058a25c25bd",
   "metadata": {},
   "outputs": [
    {
     "ename": "ModuleNotFoundError",
     "evalue": "No module named 'dask'",
     "output_type": "error",
     "traceback": [
      "\u001b[31m---------------------------------------------------------------------------\u001b[39m",
      "\u001b[31mModuleNotFoundError\u001b[39m                       Traceback (most recent call last)",
      "\u001b[36mCell\u001b[39m\u001b[36m \u001b[39m\u001b[32mIn[3]\u001b[39m\u001b[32m, line 1\u001b[39m\n\u001b[32m----> \u001b[39m\u001b[32m1\u001b[39m \u001b[38;5;28;01mimport\u001b[39;00m\u001b[38;5;250m \u001b[39m\u001b[34;01mdask\u001b[39;00m\u001b[34;01m.\u001b[39;00m\u001b[34;01mdataframe\u001b[39;00m\u001b[38;5;250m \u001b[39m\u001b[38;5;28;01mas\u001b[39;00m\u001b[38;5;250m \u001b[39m\u001b[34;01mdd\u001b[39;00m\n",
      "\u001b[31mModuleNotFoundError\u001b[39m: No module named 'dask'"
     ]
    }
   ],
   "source": [
    "import dask.dataframe as dd"
   ]
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "Python 3 (ipykernel)",
   "language": "python",
   "name": "python3"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 3
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython3",
   "version": "3.13.3"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 5
}
